﻿using DemoPathfinding.Hotfix.Components;
using ETHotfix;
using ETModel;
using PF;
using System.Linq;
using UnityEngine;

namespace DemoPathfinding.Hotfix.Handlers {
    [ActorMessageHandler(AppType.Map)]
    public class Frame_ClickMapHandler : AMActorLocationHandler<MapPlayer, Frame_ClickMap> {
        protected override void Run(MapPlayer mapPlayer, Frame_ClickMap message) {
            Vector3 target = new Vector3(message.X, message.Y, message.Z);
            //简单取第一个控制单位去寻路
            var unit = mapPlayer.GetFirstSelfUnit();
            unit?.GetComponent<UnitPathComponent>().MoveTo(target).Coroutine();

        }
    }
}